// pages/hotel/hotelDetail/comment/commentDetail/commentDetail.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        id:0,
        carouselChart: [], //轮播图动态数据
        userList:[],
        hotelOrder:[],
        imageUrlList:[],
    },

    //   五角星改变触发事件
    onChange(event) {
        this.setData({
            value: event.detail,
        });
    },
    //轮播图 
    getComment(options){
      wx.request({
        url: 'http://localhost:8080/hotel/evaluationImages/list',
        method:'GET',
        header: {
          Authorization: getApp().globalData.authorization
        },
        success:(resp)=>{
          // console.log(resp.data)
          const slicedImages = resp.data.rows.slice(0, 4);
          this.setData({
            carouselChart:slicedImages   
          })
        }
      })
      wx.request({
        url: 'http://localhost:8080/hotel/hotelEvaluation/'+options.id,
        method:'GET',
        header: {
          Authorization: getApp().globalData.authorization
        },
        success:(resp)=>{
          // console.log(resp.data)
          this.setData({
            commentList:resp.data.data
          })
        }
      })
    },
     getEevaluation() {
    wx.request({
      url: 'http://localhost:8080/hotel/hotelEvaluation/list',
      method: 'GET',
      header: {
        Authorization: getApp().globalData.authorization
      },
      success: (resp) => {
        // console.log(resp)
        this.setData({
          hotelEvaluationList: resp.data.rows
        })
        // console.log(resp.data.rows)
      }
    })
  },
  getUser(options){
    wx.request({
      url: 'http://localhost:8080/system/user/'+options.userId,
      method:'GET',
      header: {
        Authorization: getApp().globalData.authorization
      },
      success:(resp)=>{
        // console.log(resp.data)
        this.setData({
          userList:resp.data.data
        })
      }
    })
  },
  getHotelOrder(options){
    wx.request({
      url: 'http://localhost:8080/hotel/hotelOrder/'+options.hotelOrderId,
      method:'GET',
      header: {
        Authorization: getApp().globalData.authorization
      },
      success:(resp)=>{
        // console.log(resp.data)
        this.setData({
          hotelOrder:resp.data.data
        })
      }
    })
  },
  getImage(options){
    wx.request({
      url: 'http://localhost:8080/hotel/evaluationImages/'+options.imagesUrl,
      method:'GET',
      header: {
        Authorization: getApp().globalData.authorization
      },
      success:(resp)=>{
        // console.log(resp.data)
        this.setData({
          hotelOrder:resp.data.data
        })
      }
    })
  },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      console.log(options)
      this.getComment(options)
      this.getUser(options)
      this.getHotelOrder(options)
      this.getImage(options)
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {
      
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})